/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gunncs;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**
 *
 * @author anand
 */
public class CompassModel extends SensorModel{
    public static final int ID = 4;
    public static int size = RobotModel.SIZE/2;
    
    public CompassModel(){
        state = new double[2];
        state[0] = 110.0;
        state[1] = 0.0;
    }
    
    public void drawAt(Graphics g, int x, int y, double theta) {
        g.setColor(Color.ORANGE);
        Graphics2D g2d = (Graphics2D) g;
        g2d.setStroke(new BasicStroke(size/6));
        g.drawLine(x, y,(int) (x-Math.cos(Math.toRadians(theta+ -state[0]+90))*size),
                        (int) (y-Math.sin(Math.toRadians(theta+ -state[0]+90))*size));
        g.setColor(Color.BLACK);
        g.drawString("N", (int) (x-Math.cos(Math.toRadians(theta+ -state[0]+90))*size),
                			(int) (y-Math.sin(Math.toRadians(theta+ -state[0]+90))*size));

    }
}
